home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-11-18 | 5.1 KB | 252 lines | [TEXT/ALFA] |
-
- alpha::extension emacs 0.24 {
- newPref f useEmacsMenu 1 global emacsToggle
- newPref f emacLastWordIfTouching 0 global effectLastToggle
- menu::buildProc emacs emacsBindings
- emacsToggle
- effectLastToggle
- alpha::addToPreferencePage Packages emacLastWordIfTouching useEmacsMenu
- } help {file "Emacs Help"}
-
-
- proc effectLastToggle {args} {
- global emacLastWordIfTouching
- if $emacLastWordIfTouching {
- if {[info command __upcaseWord] == ""} {
- rename upcaseWord __upcaseWord
- rename downcaseWord __downcaseWord
- rename capitalizeWord __capitalizeWord
- }
- ;proc upcaseWord {} {
- set p [getPos]
- backwardWord
- set sw [getPos]
- forwardWord
- set ew [getPos]
- goto $p
- if {[pos::compare $p == $ew]} {
- backwardWord
- __upcaseWord
- } else {
- __upcaseWord
- }
- }
- ;proc downcaseWord {} {
- set p [getPos]
- backwardWord
- set sw [getPos]
- forwardWord
- set ew [getPos]
- goto $p
- if {[pos::compare $p == $ew]} {
- backwardWord
- __downcaseWord
- } else {
- __downcaseWord
- }
- }
- ;proc capitalizeWord {} {
- set p [getPos]
- backwardWord
- set sw [getPos]
- forwardWord
- set ew [getPos]
- goto $p
- if {[pos::compare $p == $ew]} {
- backwardWord
- while {![regexp {\w} [lookAt [getPos]]]} {
- forwardChar
- }
- __capitalizeWord
- } else {
- __capitalizeWord
- }
- }
- unBind 'h' <z> hiliteWord
- Bind 'h' <z> touchHiliteWord
- } else {
- if {[info command __upcaseWord] != ""} {
- rename upcaseWord {}
- rename downcaseWord {}
- rename capitalizeWord {}
-
- rename __upcaseWord upcaseWord
- rename __downcaseWord downcaseWord
- rename __capitalizeWord capitalizeWord
- unBind 'h' <z> touchHiliteWord
- Bind 'h' <z> hiliteWord
- }
- }
- }
-
- proc touchHiliteWord {} {
- if {[pos::compare [getPos]==[selEnd]]} {
- set p [getPos]
- backwardWord
- set sw [getPos]
- forwardWord
- set ew [getPos]
- goto $p
- if {[pos::compare $p == $ew]} {
- select $sw $ew
- } else {
- forwardWord
- set start [getPos]
- backwardWord
- select $start [getPos]
- }
- } else {
- forwardChar
- forwardWord
- set start [getPos]
- backwardWord
- select $start [getPos]
- }
- }
-
- proc beginningOfLogicalLine {} {
- beginningOfLine
- set p [getPos]
- set limit [pos::math [nextLineStart $p] - 1]
- set llstart [search -f 1 -r 1 -n -l $limit {[^ \t\r\n]} $p]
- if {$llstart != ""} {
- goto [lindex $llstart 0]
- }
- }
-
- proc emacsToggle {args} {
- global useEmacsMenu
- if $useEmacsMenu {
- menu::insert Edit submenu end emacs
- } else {
- menu::removeFrom Edit submenu end emacs
- emacsBindings
- }
- }
-
- # Emacs-ish bindings.
- Bind 0x33 <e> backwardDeleteWord
- Bind 'b' <es> backwardWordSelect
- Bind '<' <se> beginningOfBuffer
- Bind 'b' <X> chooseWindowStatus
- Bind 'l' <X> currentPosition
- Bind ')' <Xs> endKeyboardMacro
- Bind '>' <se> endOfBuffer
- Bind 'x' <Xz> exchangePointAndMark
- Bind 'w' <Xz> saveAs
- Bind 'e' <X> executeKeyboardMacro
- Bind 'f' <Xz> findFile
- Bind 'f' <es> forwardWordSelect
- Bind 'c' <z> prefixChar
- Bind 'x' <z> prefixChar
- Bind 'r' <e> repeatSearchBackward
- Bind 's' <e> repeatSearchForward
- Bind 's' <Xz> save
- Bind '(' <sX> startKeyboardMacro
- Bind 'o' <X> otherThing
- Bind '1' <X> zoom
- Bind 'k' <X> killWindowStatus
- Bind 'u' <X> upcaseWord
-
- Bind 'f' <e> forwardWord
- Bind 'b' <e> backwardWord
- Bind 'd' <e> deleteWord
- Bind 'h' <e> backwardDeleteWord
- Bind 'v' <e> pageBack
- Bind 'w' <e> copy
- Bind 'g' <e> gotoLine
- Bind 'e' <e> nextSentence
- Bind 'a' <e> prevSentence
- Bind 'c' <e> capitalizeWord
- Bind 'u' <e> upcaseWord
- Bind 'l' <e> downcaseWord
-
- # added next -trf
- Bind 'm' <e> beginningOfLogicalLine
- Bind 'x' <e> execute
- Bind '\ ' <e> oneSpace
- Bind '\ ' <o> oneSpace
-
- Bind 'd' <X> killRegion
-
- proc emacsBindings {} {
- global useEmacsMenu
- if $useEmacsMenu {
- Menu -n emacs {
- "/F<BforwardChar"
- "/B<BbackwardChar"
- "/D<BdeleteChar"
- "/N<BnextLine"
- "/P<BpreviousLine"
- "(-"
- "/F<IforwardWord"
- "/B<IbackwardWord"
- "/D<IdeleteWord"
- "/v<IdeleteWord"
- "/H<IbackwardDeleteWord"
- "/u<IbackwardDeleteWord"
- "(-"
- "/K<BkillLine"
- "/Y<Byank"
- "/A<BbeginningOfLine"
- "/E<BendOfLine"
- "/O<BopenLine"
- "(-"
- "/V<BpageForward"
- "/V<IpageBack"
- "/L<BcenterRedraw"
- "(-"
- "/ <BsetMark"
- "/W<Bcut"
- "/W<Icopy"
- "(-"
- "/C<IcapitalizeWord"
- "upcaseWord"
- "/L<IdowncaseWord"
- "(-"
- "/X<Iexecute"
- "/U<BiterationCount"
- "/G<BabortEm"
- }
- } else {
- Bind 'f' <z> forwardChar
- Bind 'b' <z> backwardChar
- Bind 'd' <z> deleteChar
- Bind 'n' <z> nextLine
- Bind 'p' <z> previousLine
- Bind 'f' <o> forwardWord
- Bind 'b' <o> backwardWord
- Bind 'd' <o> deleteWord
- Bind 0x33 <so> deleteWord
- Bind 'h' <o> backwardDeleteWord
- Bind 0x33 <o> backwardDeleteWord
- Bind 'k' <z> killLine
- Bind 'y' <z> yank
- Bind 'a' <z> beginningOfLine
- Bind 'e' <z> endOfLine
- Bind 'o' <z> openLine
- Bind 'v' <z> pageForward
- Bind 'v' <o> pageBack
- Bind 'l' <z> centerRedraw
- Bind '\ ' <z> setMark
- Bind 'w' <z> cut
- Bind 'w' <o> copy
- Bind 'c' <o> capitalizeWord
- Bind 'l' <o> downcaseWord
- Bind 'x' <o> execute
- Bind 'u' <z> iterationCount
- Bind 'g' <z> abortEm
- }
- }
-
- proc killRegion {} {
- set from [getMark]
- set to [getPos]
- if {[pos::compare $to < $from]} {
- deleteText $to $from
- } else {
- deleteText $from $to
- }
- }
-
-